#include<stdio.h>
#include<stdlib.h>

/*
	本实例使用了remove()函数,其语法格式如下:
		int remove(char*filename)
		该函数的作用是删除. filename 所指定的文件。
		删除成功返回0，出现错误返回-1
*/

void my_remove(char *filename)
{
	FILE *fp;
	if((fp=fopen(filename,"r"))!=NULL)
	{
		printf("fopen %s successfully!\n",filename);
		fclose(fp);
	}
	else
	{
		printf("fopen error!\n");
		exit(0);
	}
	if(remove(filename)==-1)
	{
		printf("remove %s failure!\n",filename);
		exit(-1);
	}
		printf("remove %s succeed!\n",filename);
}
int main()
{
	
	char filename[50];
	printf("please input the file's name which you want to delete:\n");
	//fgets(file,sizeof(file),stdin);
	scanf("%s",filename);
	my_remove(filename);
	
	
		
	return 0;
}
